Ext.define('appfe.ux.Download', {
    alternateClassName: 'DL',
    singleton: true,

    saveAs: function (url, filename, fileType, params) {
        Ext.Ajax.request({
            method: 'GET',
            url: url,
            params: params,
            filename: filename,
            binary: true,
            success: function (response, options) {
                Ext.Msg.hide();
                filename = options.filename,
                    bytes = response.responseBytes,
                    blob = new Blob([bytes], { type: fileType }),
                    a = document.createElement("a"),
                    evt = document.createEvent("MouseEvents");
                a.innerHTML = filename;
                a.download = filename;
                a.href = URL.createObjectURL(blob);
                evt.initEvent("click", false, false);
                a.dispatchEvent(evt);
            },
            failure: FAILED.ajax
        })
    }

});